//
//  Image+.swift
//  Casecord
//
//  Created by baozi on 2024/1/5.
//

import SwiftUI
import Kingfisher

extension SwiftUI.Image {
    static func load(_ url: String? = nil) -> KFImage {
        guard let url = url else {
            return KFImage(.init(string: ""))
        }
        let _url: String
        if url.starts(with: "http") {
            _url = url
        } else {
            let base = Env.current.fileUploadUrl;
            if url.starts(with: "/") {
                _url = base + url
            } else {
                _url = base + "/" + url
            }
        }
        return KFImage(.init(string: _url))
    }
}
